package com.lujianfei.imagesearch.widget;

import java.awt.Graphics;
import java.awt.image.BufferedImage;

import javax.swing.JPanel;

public class ImageView extends JPanel {

	private BufferedImage bufferedImage;

	public ImageView() {
		super();
		setOpaque(false);
	}

	
	public BufferedImage getImage() {
		return bufferedImage;
	}


	public void setImage(BufferedImage image) {
		this.bufferedImage = image;
		repaint();
	}


	@Override
	protected void paintComponent(Graphics g) {
		// TODO Auto-generated method stub
		super.paintComponent(g);
		if (bufferedImage != null) {
			int w = getWidth();
			int h = getHeight();
			g.drawImage(bufferedImage, 0, 0, w, h, null);
		}
	}
	
	void log(String text) {
		System.out.println("ImageView:"+text);
	}
}
